//
//  RegisterViewController.swift
//  Swift_SendMessage
//
//  Created by lanou3g on 15/11/25.
//  Copyright © 2015年 笨蛋一号后卫. All rights reserved.
//

import UIKit

class RegisterViewController: UIViewController {
    var userNameTextField : UITextField?
    var passwordTextField : UITextField?
    override func viewDidLoad() {
        super.viewDidLoad()
//        NSNotificationCenter.defaultCenter().addObserver(self, selector: ("loginSucceed"), name: "loginSucceed", object: nil)
        
             setupView()
            }
    func loginSucceed() {
        //1保存用户信息
        
        //2跳到微博信息界面
        
        
    }
    
    func setupView() {
        self.view.backgroundColor = UIColor.grayColor()
        self.userNameTextField = UITextField(frame: CGRectMake(10, 50, self.view.frame.size.width-20, 30))
        userNameTextField!.font = UIFont.boldSystemFontOfSize(18)
        userNameTextField!.placeholder = "请输入用户名字"
        userNameTextField!.textAlignment = NSTextAlignment.Center
        userNameTextField!.textColor = UIColor.brownColor()
        //        userNameTextField.backgroundColor = UIColor.grayColor()
        userNameTextField!.layer.cornerRadius = 5.0
        userNameTextField!.layer.borderWidth = 0.5
        self.view.addSubview(userNameTextField!)
        self.passwordTextField = UITextField(frame: CGRectMake(10, 100, userNameTextField!.frame.size.width, 30))
        passwordTextField!.placeholder = "请输入用户密码"
        passwordTextField!.textAlignment = NSTextAlignment.Center
        passwordTextField!.textColor = UIColor.blackColor()
        passwordTextField!.layer.cornerRadius = 5.0
        passwordTextField!.layer.borderWidth = 0.5
        passwordTextField!.font = UIFont.boldSystemFontOfSize(18)
        self.view.addSubview(passwordTextField!)
        let registerButton = UIButton(type: UIButtonType.Custom)
        registerButton.frame = CGRectMake(10, 210, passwordTextField!.frame.size.width, 30)
        registerButton.backgroundColor = UIColor.groupTableViewBackgroundColor()
        registerButton.setTitle("注册", forState: UIControlState.Normal)
        registerButton.titleLabel?.font = UIFont.boldSystemFontOfSize(15)
        registerButton.addTarget(self, action: ("registerbuttonClicked"), forControlEvents: UIControlEvents.TouchUpInside)
        self.view.addSubview(registerButton)
        
        
        

    }
    func registerbuttonClicked() {
        let loginHP = LoginHelper()

        
        loginHP.registerWithUser(self.userNameTextField!.text!, passWord: self.passwordTextField!.text!)
   
       
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
